Fix JAX array leak from PointSolver into Grid2DIrregular#410
Merged
Conversation
When the solver uses a JAX backend, the final boolean-indexed solution was a JAX DeviceArray. Wrapping it in Grid2DIrregular without conversion caused downstream np.array() calls in the visualizer to raise: ValueError: object __array__ method not producing an array Fix: convert solution to numpy via np.asarray() before constructing the return Grid2DIrregular. Safe because solve() is never called inside jax.jit (variable-length boolean indexing prevents it). Also updates the Returns docstring to document the numpy-backed guarantee. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PointSolver.solve()runs with a JAX backend, the boolean-indexedsolutionis a JAXDeviceArray. Wrapping it directly inaa.Grid2DIrregularproduced a JAX-backed object that propagated throughresult.pyintoPositionsLH.positionsand eventually into the visualizer.plotter.pycallsnp.array(positions.array)which raisedValueError: object __array__ method not producing an arrayon certain JAX versions.np.asarray()before the finalGrid2DIrregularconstruction inPointSolver.solve(). This is safe —solve()is never called insidejax.jit(variable-length boolean indexing prevents it), and all downstream consumers expect numpy-backed coordinates.Returnsdocstring to document the numpy-backed guarantee.Test plan
python -m pytest test_autolens/)np.asarray()on a numpy array is a zero-copy no-op — no regression on the numpy path🤖 Generated with Claude Code